<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>switch</title>
</head>
<body>
   <h1>switch</h1>
   <div th:object="${user}">
       <div th:switch="*{role}">
           <div th:case="admin">管理员</div>
           <div th:case="normal">普通用户</div>
          <div th:case="*">其他用户</div>
       </div>
   </div>

   <script th:inline="javascript">
         const name = [[${user.name}]]
         console.log(name);
   </script>

</body>
</html>